<?php

namespace frontend\models\search;

use Yii;
use yii\base\Model;


class Search extends Model
{
	public $search_content;   //搜索内容

	/**
	 * @inheritdoc 验证规则
	 */
	public function rules()
	{
		return [
			['search_content','string','max'=>60,'message'=>'最大长度不能超过20字'],
		];
	}

	/**
	 * @inheritdoc
	 */
	public function attributeLabels()
	{
		return [
			'search_content' => '搜索',
		];
	}

	/**
	 * @inheritdoc 直播课程搜索方法
	 */
	static public function directseacher($course,$type)
	{
		$sql = "select * from edu_course where course_id in (".substr($course,1).") and type_id = $type limit 8";
		$command = \Yii::$app->db->createCommand($sql);
		$search = $command->queryAll();
		return $search;
	}

	/**
	 * @inheritdoc 直播课程获取条数方法
	 */
	static public function directcount($course,$type)
	{
		$sql = "select count(*) as count from edu_course where course_id in (".substr($course,1).") and type_id = $type limit 8";
		$command = \Yii::$app->db->createCommand($sql);
		$directcount = $command->queryAll();
		return $directcount;
	}

	/**
	 * @inheritdoc 下载方法
	 */
	static public function softseacher($soft)
	{
		$sql = "select * from edu_soft where soft_id in (".substr($soft,1).") limit 8";
		$command = \Yii::$app->db->createCommand($sql);
		$softseacher = $command->queryAll();
		return $softseacher;
	}

	/**
	 * @inheritdoc 行业资讯方法
	 */
	static public function articleseacher($article)
	{
		$sql = "select * from edu_article where article_id in (".substr($article,1).") limit 8";
		$command = \Yii::$app->db->createCommand($sql);
		$articleseacher = $command->queryAll();
		return $articleseacher;
	}

	/**
	 * @inheritdoc 师资力量方法
	 */
	static public function teacherseacher($teacher)
	{
		$sql = "select * from edu_teacher_info where teacher_id in(".substr($teacher,1).") limit 8";
		$command = \Yii::$app->db->createCommand($sql);
		$teacherseacher = $command->queryAll();
		return $teacherseacher;
	}
}
